<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      body {
        margin: 0;
        padding: 0;
      }

      .username {
        position: absolute;
        left: 347px;
        top: 250px;
        border-radius: 5px;
        height: 24px;
      }

      button {
        background: transparent;
        outline: none;
        border: none;
        color: white;
      }

      .heroShow {
        width: 50px;
        height: 50px;
      }

      .sub {
        position: absolute;
        left: 351px;
        top: 288px;
        width: 126px;
        color: white;
        font-weight: bold;
        font-size: 18px;
      }

      .geme {
        position: relative;
      }

      .heroBtn {
        position: absolute;
        left: 45px;
        top: 8px;
        font-size: 14px;
      }

      .skinBtn {
        position: absolute;
        top: 8px;
        left: 105px;
        font-size: 14px;
      }

      .userView {
        position: absolute;
        /* width: 80px; */
        top: 34px;
        left: 720px;
      }

      .userView img {
        width: 40px;
        height: 40px;
      }

      .chioseusername {
        display: block;
        color: rgb(255, 215, 0);
        text-align: center;
        font-size: 12px;
        font-weight: bold;
      }

      .skillsView {
        position: absolute;
        display: flex;
        flex-direction: column;
        left: 660px;
        top: 200px;
      }

      .skillsView img {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
      }

      .heroView {
        width: 120px;
        position: absolute;
        margin-top: 40px;
        margin-left: 20px;
        display: flex;
        flex-wrap: wrap;
      }

      .skinView {
        width: 130px;
        position: absolute;
        margin-top: 40px;
        margin-left: 20px;
        display: flex;
        flex-wrap: wrap;
      }

      .heroView img {
        width: 50px;
        height: 50px;
      }

      .skinView img {
        width: 50px;
        height: 50px;
      }

      .heroItem {
        margin-left: 10px;
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        color: gray;
        align-items: center;
        font-size: 12px;
      }

      .skinItem {
        margin-left: 10px;
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        color: gray;
        align-items: center;
        font-size: 12px;
      }

      .skinShow {
        position: absolute;
        left: 320px;
        top: 40px;
      }

      .login {
        display: block;
      }

      .game {
        display: none;
      }

      .heroContainer {
        display: block;
      }

      .skinContainer {
        display: none;
      }
    </style>
  </head>

  <body>
    <!-- 登录页面 -->
    <div class="login">
      <input class="username" /> <button class="sub">登录</button>
      <img src="../静态文件模块化 --类/sources/login.JPG" alt="" />
    </div>
    <!-- 游戏选择页面 -->
    <div class="game">
      <button class="heroBtn">英雄</button>
      <div class="heroContainer">
        <div class="heroView">
          <div class="heroItem">
            <img src="../静态文件模块化 --类/sources/heroes/yase1.png" />
            <span>亚瑟</span>
          </div>
          <div class="heroItem">
            <img src="../静态文件模块化 --类/sources/heroes/luban1.png" />
            <span>鲁班</span>
          </div>
        </div>
      </div>

      <button class="skinBtn">皮肤</button>
      <div class="skinContainer">
        <div class="skinView">
          <!-- <div class="skinItem">
            <img src="./sources/heroes/yase1.png" />
            <span>经典</span>
          </div>
          <div class="skinItem">
            <img src="./sources/heroes/yase2.png" />
            <span>死亡骑士</span>
          </div>
          <div class="skinItem">
            <img src="./sources/heroes/yase2.png" />
            <span>死亡骑士</span>
          </div> -->
        </div>
      </div>

      <div class="skinShow">
        <img src="../静态文件模块化 --类/sources/skins/301660.png" alt="" />
      </div>
      <div class="userView">
        <div class="heroShow">
          <!-- <img src="./sources/heroes/yase1.png" /> -->
        </div>
        <span class="chioseusername"></span>
      </div>

      <div class="skillsView">
        <img src="../静态文件模块化 --类/sources/skills/11210.png" />
        <img src="../静态文件模块化 --类/sources/skills/11220.png" />
        <img src="../静态文件模块化 --类/sources/skills/11230.png" />
      </div>
      <div></div>
      <img src="../静态文件模块化 --类/sources/chiose.JPG" />
    </div>
    <!-- <script src="./js/game.js"></script> -->
    <script type="module">
      //   import Game from "./js/game.js";
      /*
        英雄  技能  皮肤
        玩家  游戏管理 （组织逻辑的）

        // 只有数据
        Game{
            login(){
                player:{
                heroes:[
                    {
                        亚瑟
                        skills:【技能一、技能二、技能三】
                        skins:【皮肤一、皮肤二、皮肤三..】
                        ico:''
                    }
                    {
                        鲁班
                        skills:
                        skins
                    }
                ]
            }
            }
        }


        ----组织视图逻辑
        --- 把数据和视图分开
        */

      //登录
      //登录页面
      let login = document.querySelector(".login");

      // 游戏页面
      let game = document.querySelector(".game");
      // 登录按钮
      let btn = document.querySelector(".sub");
      // 用户输入框
      let username = document.querySelector(".username");
      let name = document.querySelector(".chioseusername");
      let yingxiong = document.querySelectorAll(".heroItem");
      let yingxiongimg = document.querySelector(".skinShow");
      let jineng = document.querySelector(".skillsView");
      let qdyingxiong = document.querySelector(".heroShow");
      let skinBtn = document.querySelector(".skinBtn");
      let heroView = document.querySelector(".heroView");
      let skinView = document.querySelector(".skinView");
      let skinContainer = document.querySelector(".skinContainer");
      // let skinItem = document.querySelectorAll(".skinItem");
      let btns = document.querySelectorAll("button");
      console.log(btns[1], btns[2]);

      btn.onclick = function () {
        let password = username.value;
        if (password == 123456) {
          console.log("点击了");
          login.style.display = "none";
          game.style.display = "block";
          name.innerHTML = password;
        } else {
          alert("用户名或密码错误");
        }
      };
      btns[1].onclick = function () {
        console.log("点击了英雄按钮");
        // heroView.style.display = "block";
        heroView.style.display = "flex";
        skinContainer.style.display = "none";
      };
      btns[2].onclick = function () {
        console.log("点击了皮肤按钮");
        heroView.style.display = "none";
        skinContainer.style.display = "block";
      };
      //英雄
      yingxiong.forEach(function (item, key) {
        yingxiongimg.innerHTML = "";
        jineng.innerHTML = "";
        item.onclick = function () {
          console.log(key);
          if (key === 0) {
            // 英雄
            yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301660.png" alt="" />`;
            // 技能
            jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/16610.png" />
        <img src="../静态文件模块化 --类/sources/skills/16620.png" />
        <img src="../静态文件模块化 --类/sources/skills/16630.png" />`;
            // 小头像
            qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/yase1.png" /> `;

            //亚瑟皮肤切换
            skinBtn.onclick = function () {
              console.log("123");
              heroView.style.display = "none";
              skinContainer.style.display = "block";
              skinView.innerHTML = `<div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/yase1.png" />
            <span>经典</span>
          </div>
          <div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/yase2.png" />
            <span>死亡骑士</span>
          </div>
          <div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/yase3.png" />
            <span>狮心王</span>
          </div>
          `;
              let skinItem = document.querySelectorAll(".skinItem");
              console.log(skinItem);
              // yingxiong.style.display = "";
              // heroView.style.display = "none";
              skinContainer.style.display = "block";
              // console.log(skinItem);
              skinItem.forEach(function (item, key) {
                item.onclick = function () {
                  console.log(key);
                  if (key === 0) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301660.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/16610.png" />
        <img src="../静态文件模块化 --类/sources/skills/16620.png" />
        <img src="../静态文件模块化 --类/sources/skills/16630.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/yase1.png" /> `;
                  } else if (key === 1) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301661.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/16610.png" />
        <img src="../静态文件模块化 --类/sources/skills/16620.png" />
        <img src="../静态文件模块化 --类/sources/skills/16630.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/yase2.png" /> `;
                  } else if (key === 2) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301662.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/16610.png" />
        <img src="../静态文件模块化 --类/sources/skills/16620.png" />
        <img src="../静态文件模块化 --类/sources/skills/16630.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/yase3.png" /> `;
                  }
                };
              });
            };
          } else if (key === 1) {
            yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301120.png" alt="" />`;
            jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/11210.png" />
        <img src="../静态文件模块化 --类/sources/skills/11220.png" />
        <img src="../静态文件模块化 --类/sources/skills/11230.png" />`;
            qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/luban1.png" /> `;

            // 鲁班皮肤切换
            skinBtn.onclick = function () {
              console.log("123");
              heroView.style.display = "none";
              skinContainer.style.display = "block";
              skinView.innerHTML = `<div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/luban1.png" />
            <span>经典</span>
          </div>
          <div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/luban2.png" />
            <span>木偶奇遇记</span>
          </div>
          <div class="skinItem">
            <img src="../静态文件模块化 --类/sources/heroes/luban3.png" />
            <span>福禄兄弟</span>
          </div>`;
              // heroView.style.display = "none";
              skinContainer.style.display = "block";
              let skinItem = document.querySelectorAll(".skinItem");
              console.log(skinItem);
              skinItem.forEach(function (item, key) {
                item.onclick = function () {
                  console.log(key);
                  if (key === 0) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301120.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/11210.png" />
        <img src="../静态文件模块化 --类/sources/skills/11220.png" />
        <img src="../静态文件模块化 --类/sources/skills/11230.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/luban1.png" /> `;
                  } else if (key === 1) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301121.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/11210.png" />
        <img src="../静态文件模块化 --类/sources/skills/11220.png" />
        <img src="../静态文件模块化 --类/sources/skills/11230.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/luban2.png" /> `;
                  } else if (key === 2) {
                    yingxiongimg.innerHTML = `<img src="../静态文件模块化 --类/sources/skins/301122.png" alt="" />`;
                    jineng.innerHTML = `<img src="../静态文件模块化 --类/sources/skills/11210.png" />
        <img src="../静态文件模块化 --类/sources/skills/11220.png" />
        <img src="../静态文件模块化 --类/sources/skills/11230.png" />`;
                    qdyingxiong.innerHTML = `<img src="../静态文件模块化 --类/sources/heroes/luban3.png" /> `;
                  }
                };
              });
            };
          }
        };
      });
    </script>
  </body>
</html>
